<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<!--     <link rel="icon" href="../../favicon.ico"> -->

    <title>后台登录</title>
    <link rel="shortcut icon" href="${path}/favicon.ico"/> 
	<link href="${path}/css/bootstrap.min.css" rel="stylesheet">
	
	<style type="text/css">
		body {
			background: #eeeeee url(${path}/img/bg.jpg) top left repeat;
		}
		#loginForm {
			margin-top: 100px;
		}
	</style>
  </head>

  <body>

    <div class="container">
		<div class="row">
  			<div class="col-md-4"></div>
  			<div class="col-md-4"  id="loginForm">
  				<div class="panel panel-primary">
				  <div class="panel-heading"><h1></h1></div>
				  <div class="panel-body">
					   <div class="form-group">
					      <label for="vUser" class="sr-only">用户名</label>
					      <input type="text" class="form-control" id="username" placeholder="用户名">
					   </div>
					   <div class="form-group">
					      <label for="vPassword" class="sr-only">密码</label>
					      <input type="password" class="form-control" id="password" placeholder="密码">
					   </div>
					   <button class="btn btn-primary btn-block" id="login">登录</button>
				  </div>
				</div>
				<div id="msg" hidden="hidden">
					<div class="alert alert-danger">用户名或密码错误</div>
				</div>
  			</div>
  			<div class="col-md-4"></div>
		</div>
    </div> <!-- /container -->
    
    <script src="${path}/js/jquery-1.11.1.min.js"></script>
 	<script src="${path}/js/sha1.js"></script>
    <script type="text/javascript">
	    	$('#login').click(function(){
	    		$.ajax({
	    			url:'${path}/admin/login',
	    			type:'post',
	    			dataType:'json',
	    			data:{
	    				'user.username':$('#username').val(),
	    				'user.password':hex_sha1($('#password').val())
	    			},
	    			success : function(data){
	    				if(data.error){
	    					$("#msg").fadeIn("fast",function(){
	    						$("#msg").fadeOut(4000)
	    					});
	    				}else{
	    					location.href="${path}/admin";
	    				}
	    			}
	    		});
	    	});
	    </script>
  </body>
</html>
